<template>
	<view id="recommend" class="recommend">
		<view class="header">
			<view class="line"></view>
			<view class="title">看了又看</view>
		</view>
		<view class="list">
			<view class="item" v-for="(item, index) in recommendList" :key="index">
				<image class="cover" mode="aspectFill" :src="item.productImageList[0]?.pic"></image>
				<view class="title">{{ item.name }}</view>
				<view class="price">
					<view class="symbol">￥</view>
					<view class="value">{{ toFixed(item.promotionPrice) }}起</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script lang="ts" setup>
	import { toFixed } from '@/utils';
	
	const props = defineProps({
		productDetail: {
			type: Object,
			defualt: () => ({}),
		},
	});
	
	// 推荐列表
	const recommendList = Array(6).fill(props.productDetail);
</script>

<style lang="scss" scoped>
	.recommend {
		padding: 0 24rpx 6rpx;
		background-color: #EEEEEE;
		.header {
			width: 100%;
			height: 96rpx;
			background: #EEEEEE;
			position: relative;
			padding-bottom: 6rpx;
			.line {
				width: 326rpx;
				height: 2rpx;
				background: #D8D8D8;
				position: absolute;
				left: 0;
				right: 0;
				top: 0;
				bottom: 0;
				margin: auto;
			}
			.title {
				width: 188rpx;
				line-height: 96rpx;
				font-size: 24rpx;
				font-weight: bold;
				color: #242424;
				text-align: center;
				margin: auto;
				background-color: #EEEEEE;
				position: relative;
			}
		}
		.list {
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;
			.item {
				width: 342rpx;
				background: #FFFFFF;
				border-radius: 16rpx;
				padding: 20rpx;
				box-sizing: border-box;
				margin-bottom: 18rpx;
				.cover {
					width: 302rpx;
					height: 302rpx;
					background: #D8D8D8;
					border-radius: 12rpx;
					display: block;
					margin-bottom: 20rpx;
				}
				.title {
					line-height: 28rpx;
					font-size: 28rpx;
					font-weight: bold;
					color: #242424;
					margin-bottom: 20rpx;
				}
				.price {
					display: flex;
					align-items: flex-end;
					font-weight: bold;
					color: #EB4836;
					text {
						line-height: 22rpx;
						font-size: 28rpx;
					}
					.symbol {
						line-height: 22rpx;
						font-size: 24rpx;
					}
					.value {
						line-height: 24rpx;
						font-size: 32rpx;
						font-weight: bold;
						color: #EB4836;
					}
					.decimal {
						line-height: 20rpx;
						font-size: 26rpx;
					}
					.price-bytime {
						line-height: 22rpx;
						font-size: 22rpx;
						color: #242424;
					}
				}
			}
		}
	}
</style>